package game.core.effect
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	import game.core.util.DisplayUtil;
	
	public class BallEffect extends Sprite
	{
		private var target:MovieClip;
		
		private var callback:Function;
		
		private var args:Array;
		
		public function BallEffect(mc:MovieClip,callback:Function = null,args:Array = null)
		{
			this.target = mc;
			this.callback = callback;
			this.args;
		}
		
		public function play():void {
			this.target.addFrameScript(this.target.totalFrames - 1,handler);
		}
		
		private function handler():void {
			this.target.addFrameScript(this.target.totalFrames - 1, null);
			this.target.stop();
			DisplayUtil.removeChild(this.target.parent,this.target);
			if(this.callback != null){
				this.callback.apply(null,this.args);
			}
		}
	}
}